package com.beans.user;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

import com.sql.DBFactory;
import com.util.MD5;

public class AdminDetail {
	 private Connection conn=null;
     private Statement stmt=null;
     private ResultSet rs=null;
     private ResultSet rs1=null;
     private String sql=null;
     MD5 md5=new MD5();
     private int ID;
     private String AdminNo;
     private String AdminName;
     private String AdminPassword;
     private String GroupNo;
     private String Memo;
     private String GroupName;

     public void setAdminInfo(String AdminNo)
     {
             sql="select * from admin where admin_id="+AdminNo;                ;
             try
             {
                     conn=DBFactory.getConnection();
                     stmt=conn.createStatement();
                     rs=stmt.executeQuery(sql);
                     if(rs.next())
                     {
                             ID=rs.getInt(1);
                             AdminName=rs.getString(2);
                             AdminPassword=rs.getString(3);
                             GroupNo=rs.getString(6);
                             Memo=rs.getString(7);
                             sql=
                                 "select group_name from admingroup where group_no='"
                                 +GroupNo+"'";
                             stmt=conn.createStatement();
                             rs1=stmt.executeQuery(sql);
                             if(rs1.next())
                             {
                                     GroupName=rs1.getString("group_name");
                             }
                     }
             }
             catch(Exception e)
             {
                     System.out.println(e.toString());
                     System.out.println("the sql is: "+sql);
             }
             finally
             {
                     try
                     {
                             rs.close();
                             rs1.close();
                             stmt.close();
                             conn.close();
                     }
                     catch(SQLException sqlex)
                     {
                     }
             }
     }

     public int getID()
     {
             return ID;
     }

     public String getAdminNo()
     {
             return AdminNo;
     }

     public String getAdminName()
     {
             return AdminName;
     }

     public String getAdminPassword()
     {
             return AdminPassword;
     }

     public String getGroupNo()
     {
             return GroupNo;
     }

     public String getGroupName()
     {
             return GroupName;
     }

     public String getMemo()
     {
             return Memo;
     }

}
